##
# Coordinate
#
# Description: This file contains a Coordinate class which contains a x and a y position.
#
# Since 12-8-2013
#

import math


class Coordinate:

    def __init__(self, x, y):
        self.x = x
        self.y = y

    ##
    # __eq__
    #
    # Description: checks if one coordinate is equal to another
    #
    def __eq__(self, other):
        return self.x == other.x and self.y == other.y

    ##
    # __add__
    #
    # Description: Creates a new coordinate which is the sum of the given coordinates
    #
    def __add__(self, other):
        return Coordinate(self.x + other.x, self.y + other.y)

    ##
    # __sub__
    #
    # Description: Creates a new coordinate with the difference of the given coordinates
    #
    def __sub__(self, other):
        return Coordinate(self.x - other.x, self.y - other.y)

    ##
    # manhattan_distance
    #
    # Description: gives the distance in non-diagonal lines  between two points
    def manhattan_distance(self, other):
        distX = math.fabs(self.x - other.x)
        distY = math.fabs(self.y - other.y)
        return distX + distY

    ##
    # pythagorean_distance
    #
    # Description: gives the distance between two points using a single diagonal line
    #
    def pythagorean_distance(self, other):
        distX = (self.x - other.x) ** 2
        distY = (self.y - other.y) ** 2
        return math.sqrt(distX + distY)
